Bootstrap.mak clean target(s)

Bootstrap can now clean itself using make -f Bootstrap.mak <platform>-clean

* Factorize cleanup tasks in two targets
	* windows-clean for windows systems
	* nix-clean: For all UNIX-based systems
* Add a "*-clean" target counterpart for each target as an alias of windows-clean or nix-clean
* Make each target invoke its *-clean target before running
* Replace use of $? / $** by explicit $(SRC) in build rules
	They cannot be used anymore due to the presence of the *-clean target in dependency list
This commit is contained in:
Renaud Guillard 2020-05-24 13:20:53 +02:00 committed by Renaud Guillard
parent c620b80566
commit 8f437877bf

View File

@ -39,6 +39,12 @@ SRC = src/host/*.c \
$(LUA_DIR)/lzio.c \ $(LUA_DIR)/lzio.c \
HOST_PLATFORM= none HOST_PLATFORM= none
.PHONY: default none nix-clean windows-clean \
mingw-clean mingw macosx macosx-clean osx-clean osx \
linux-clean linux bsd-clean bsd solaris-clean solaris \
haiku-clean haiku windows-base windows windows-msbuild
default: $(HOST_PLATFORM) default: $(HOST_PLATFORM)
none: none:
@ -51,74 +57,77 @@ none:
@echo "where HOST_PLATFORM is one of these:" @echo "where HOST_PLATFORM is one of these:"
@echo " osx linux bsd" @echo " osx linux bsd"
mingw: $(SRC) nix-clean:
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build
$(SILENT) rm -rf ./obj
windows-clean:
$(SILENT) if exist .\bin rmdir /s /q .\bin $(SILENT) if exist .\bin rmdir /s /q .\bin
$(SILENT) if exist .\build rmdir /s /q .\build $(SILENT) if exist .\build rmdir /s /q .\build
$(SILENT) if exist .\obj rmdir /s /q .\obj $(SILENT) if exist .\obj rmdir /s /q .\obj
mingw-clean: windows-clean
mingw: mingw-clean
if not exist build\bootstrap (mkdir build\bootstrap) if not exist build\bootstrap (mkdir build\bootstrap)
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lole32 -lversion $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lole32 -lversion
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --os=windows --to=build/bootstrap --cc=mingw gmake2 ./build/bootstrap/premake_bootstrap --os=windows --to=build/bootstrap --cc=mingw gmake2
$(MAKE) -C build/bootstrap config=$(CONFIG)_$(PLATFORM) $(MAKE) -C build/bootstrap config=$(CONFIG)_$(PLATFORM)
macosx: osx macosx: osx
osx: $(SRC) macosx-clean: osx-clean
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build osx-clean: nix-clean
$(SILENT) rm -rf ./obj
osx: osx-clean
mkdir -p build/bootstrap mkdir -p build/bootstrap
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_MACOSX -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" -framework CoreServices -framework Foundation -framework Security -lreadline $? $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_MACOSX -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" -framework CoreServices -framework Foundation -framework Security -lreadline $(SRC)
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG) $(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
linux: $(SRC) linux-clean: nix-clean
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build linux: linux-clean
$(SILENT) rm -rf ./obj
mkdir -p build/bootstrap mkdir -p build/bootstrap
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm -ldl -lrt $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm -ldl -lrt
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG) $(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
bsd: $(SRC) bsd-clean: nix-clean
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build bsd: bsd-clean
$(SILENT) rm -rf ./obj
mkdir -p build/bootstrap mkdir -p build/bootstrap
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
$(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG) $(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG)
solaris: $(SRC) solaris-clean: nix-clean
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build solaris: solaris-clean
$(SILENT) rm -rf ./obj
mkdir -p build/bootstrap mkdir -p build/bootstrap
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
$(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG) $(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG)
haiku: $(SRC) haiku-clean: nix-clean
$(SILENT) rm -rf ./bin
$(SILENT) rm -rf ./build haiku: haiku-clean
$(SILENT) rm -rf ./obj
mkdir -p build/bootstrap mkdir -p build/bootstrap
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_BSD_SOURCE -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lbsd $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_BSD_SOURCE -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lbsd
./build/bootstrap/premake_bootstrap embed ./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG) $(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
windows-base: $(SRC) windows-base: windows-clean
$(SILENT) if exist .\bin rmdir /s /q .\bin
$(SILENT) if exist .\build rmdir /s /q .\build
$(SILENT) if exist .\obj rmdir /s /q .\obj
if not exist build\bootstrap (mkdir build\bootstrap) if not exist build\bootstrap (mkdir build\bootstrap)
cl /Fo.\build\bootstrap\ /Fe.\build\bootstrap\premake_bootstrap.exe /DPREMAKE_NO_BUILTIN_SCRIPTS /I"$(LUA_DIR)" /I"$(LUASHIM_DIR)" user32.lib ole32.lib advapi32.lib $** cl /Fo.\build\bootstrap\ /Fe.\build\bootstrap\premake_bootstrap.exe /DPREMAKE_NO_BUILTIN_SCRIPTS /I"$(LUA_DIR)" /I"$(LUASHIM_DIR)" user32.lib ole32.lib advapi32.lib $(SRC)
.\build\bootstrap\premake_bootstrap.exe embed .\build\bootstrap\premake_bootstrap.exe embed
.\build\bootstrap\premake_bootstrap --to=build/bootstrap $(MSDEV) .\build\bootstrap\premake_bootstrap --to=build/bootstrap $(MSDEV)