From 3dfd6c11ed5599ab8baf4a6114f4ccb34150de6e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 5 May 2024 10:24:40 +0200 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d159bef --- /dev/null +++ b/Makefile @@ -0,0 +1,177 @@ +.POSIX: + +CONFIGFILE = config.mk +include $(CONFIGFILE) + +OS = linux +# Linux: linux +# Mac OS: macos +# Windows: windows +include mk/$(OS).mk + + +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) +LIB_NAME = exec + + +OBJ =\ + libexec_add_pluming.o\ + libexec_add_output_document.o\ + libexec_add_output_fd.o\ + libexec_clear_environ.o\ + libexec_close.o\ + libexec_construct_command.o\ + libexec_copy_environ.o\ + libexec_destroy_command.o\ + libexec_destroy_document.o\ + libexec_destroy_pluming.o\ + libexec_destroy_result.o\ + libexec_dup.o\ + libexec_exec.o\ + libexec_get_documents.o\ + libexec_getenv.o\ + libexec_getenv_last.o\ + libexec_init_command.o\ + libexec_input_data_copy.o\ + libexec_input_data_gift.o\ + libexec_input_text_copy.o\ + libexec_input_text_gift.o\ + libexec_open.o\ + libexec_openat.o\ + libexec_openat2.o\ + libexec_pipe_commands.o\ + libexec_pipe_commandsv.o\ + libexec_pipe_commandsvn.o\ + libexec_put_arguments.o\ + libexec_put_argumentsn.o\ + libexec_putenv.o\ + libexec_putenv_append.o\ + libexec_putenv_noclobber.o\ + libexec_putenv_noreplace.o\ + libexec_putenv_prepend.o\ + libexec_putenv_replace.o\ + libexec_putenvf.o\ + libexec_putenvf_append.o\ + libexec_putenvf_noclobber.o\ + libexec_putenvf_noreplace.o\ + libexec_putenvf_prepend.o\ + libexec_putenvf_replace.o\ + libexec_recv_document.o\ + libexec_renumber_fd.o\ + libexec_run.o\ + libexec_run_pipeline.o\ + libexec_send_document.o\ + libexec_set_environ.o\ + libexec_set_exec_fd.o\ + libexec_set_exec_path.o\ + libexec_set_executable.o\ + libexec_set_require_path.o\ + libexec_setenv.o\ + libexec_setenv_append.o\ + libexec_setenv_noclobber.o\ + libexec_setenv_noreplace.o\ + libexec_setenv_prepend.o\ + libexec_setenv_replace.o\ + libexec_setenvf.o\ + libexec_setenvf_append.o\ + libexec_setenvf_noclobber.o\ + libexec_setenvf_noreplace.o\ + libexec_setenvf_prepend.o\ + libexec_setenvf_replace.o\ + libexec_spawn.o\ + libexec_unsetenv.o\ + libexec_unsetenv_first.o\ + libexec_unsetenv_last.o\ + libexec_vconstruct_command.o\ + libexec_vpipe_commands.o\ + libexec_vputenvf.o\ + libexec_vputenvf_append.o\ + libexec_vputenvf_noclobber.o\ + libexec_vputenvf_noreplace.o\ + libexec_vputenvf_prepend.o\ + libexec_vputenvf_replace.o\ + libexec_vrun.o\ + libexec_vsetenvf.o\ + libexec_vsetenvf_append.o\ + libexec_vsetenvf_noclobber.o\ + libexec_vsetenvf_noreplace.o\ + libexec_vsetenvf_prepend.o\ + libexec_vsetenvf_replace.o + +HDR =\ + libexec.h\ + common.h + +LOBJ = $(OBJ:.o=.lo) +TOBJ = $(OBJ:.o=.to) +TEST = $(OBJ:.o=.test) + + +all: libexec.a libexec.$(LIBEXT) $(TEST) +$(OBJ): $(HDR) +$(LOBJ): $(HDR) +$(TOBJ): $(HDR) +$(TEST): testhelp.o libexec.a + +.c.o: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +.c.lo: + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +.c.to: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -DTEST + +.to.test: + $(CC) -o $@ $< testhelp.o libexec.a $(LDFLAGS) + +libexec.a: $(OBJ) + @rm -f -- $@ + $(AR) rc $@ $(OBJ) + $(AR) ts $@ > /dev/null + +libexec.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) + +check: $(TEST) + @status=0;\ + for t in $(TEST); do\ + if test -z "$(CHECK_PREFIX)"; then\ + printf './%s\n' "$$t";\ + else\ + printf '%s ./%s\n' "$(CHECK_PREFIX)" "$$t";\ + fi;\ + if ! $(CHECK_PREFIX) "./$$t"; then\ + printf '\033[1;31m%s failed!\033[m\n' "$$t";\ + status=1;\ + fi;\ + done;\ + exit $$status + +install: libexec.a libexec.$(LIBEXT) + mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" + mkdir -p -- "$(DESTDIR)$(PREFIX)/include" + cp -- libexec.a "$(DESTDIR)$(PREFIX)/lib/" + cp -- libexec.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBMINOREXT)" + ln -sf -- libexec.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBMAJOREXT)" + ln -sf -- libexec.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBEXT)" + cp -- libexec.h "$(DESTDIR)$(PREFIX)/include/" + +uninstall: + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libexec.a" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBMINOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libexec.$(LIBEXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/include/libexec.h" + +clean: + -rm -f -- *.o *.a *.lo *.to *.su *.so *.so.* *.dll *.dylib + -rm -f -- *.gch *.gcov *.gcno *.gcda *.test *.$(LIBEXT) + +.SUFFIXES: +.SUFFIXES: .lo .o .c .to .test + +.PHONY: all check install uninstall clean -- cgit v1.2.3-70-g09d2