lpsantil / rt0

A minimal C runtime for Linux i386 & x86_64
BSD 2-Clause "Simplified" License
579 stars 30 forks source link

Add `make uninstall`. #2

Closed ryanmjacobs closed 9 years ago

lpsantil commented 9 years ago

I like the idea of adding make uninstall, but I feel make install ought to create a footprint file and then make uninstall should use that to do rm.

ryanmjacobs commented 9 years ago

Could you please clarify the footprint file idea? Is it something like creating a list of installed files during the execution of make install, then looping through that in make uninstall?

lpsantil commented 9 years ago

Exactly. A list of fully qualified file paths stored somewhere. That's how many package managers work as well. Heck, might even be able to get away with just caching $(INSTALL_PATH). The trick is to automatically generate the footprint file every time.

ryanmjacobs commented 9 years ago

Okay, make install generates a footprint file on each install (and make uninstall uses that footprint file to uninstall). I'm not sure if this is the best way to implement it, but I don't know any other way other than using a more complex shell script.

Still, I think there is yet a better way.

lpsantil commented 9 years ago

I took a crack at it. Tell me what you think [https://github.com/lpsantil/rt0/commit/5362f689f30aadea7c5907ac9ac6925cc6c3ccd6].

lpsantil@host:~/build/rt0$ DEST=. PREFIX=out make install
mkdir -p ./out/include/rt0 ./out/lib
rm -f .footprint
‘include/rt0/rt0.h’ -> ‘./out/include/rt0/rt0.h’
‘include/rt0/syscall.h’ -> ‘./out/include/rt0/syscall.h’
‘lib/librt0.a’ -> ‘./out/lib/librt0.a’
lpsantil@host:~/build/rt0$ cat .footprint && tree out/
./out/include/rt0/rt0.h
./out/include/rt0/syscall.h
./out/lib/librt0.a
out/
├── include
│   └── rt0
│       ├── rt0.h
│       └── syscall.h
└── lib
    └── librt0.a

3 directories, 3 files
lpsantil@host:~/build/rt0$ make uninstall
removed ‘./out/include/rt0/rt0.h’
removed ‘./out/include/rt0/syscall.h’
removed ‘./out/lib/librt0.a’
ryanmjacobs commented 9 years ago

Thanks, that looks much better than what I had.