diff --git a/.gitignore b/.gitignore index 9530f0ac..00d50c9e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ aclocal.* *.a config.mak preload/exported.h -preload/ldexportlist +preload/export.map preload/wrappers.c obj-32 obj-64 @@ -29,5 +29,4 @@ utils/sb2-interp-wrapper .version preload/privatewrappers.c preload/privatewrappers.h -preload/export.map include/scratchbox2_version.h diff --git a/Makefile b/Makefile index 766e1dbe..9b18b800 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,14 @@ TOPDIR = $(CURDIR) OBJDIR = $(TOPDIR) SRCDIR = $(TOPDIR) -VPATH = $(SRCDIR) +VPATH = $(SRCDIR):$(OBJDIR) MACH := $(shell uname -m) OS := $(shell uname -s) ifeq ($(OS),Linux) LIBSB2_LDFLAGS = -Wl,-soname=$(LIBSB2_SONAME) \ - -Wl,--version-script=preload/export.map + -Wl,--version-script=$(OBJDIR)/preload/export.map SHLIBEXT = so else @@ -107,10 +107,11 @@ do-all: $(targets) echo $(PACKAGE_VERSION) > .version; \ fi) -include/scratchbox2_version.h: .version Makefile - echo "/* Automatically generated file. Do not edit. */" >include/scratchbox2_version.h - echo '#define SCRATCHBOX2_VERSION "'`cat .version`'"' >>include/scratchbox2_version.h - echo '#define LIBSB2_SONAME "'$(LIBSB2_SONAME)'"' >>include/scratchbox2_version.h +$(OBJDIR)/include/scratchbox2_version.h: .version Makefile + mkdir -p $(OBJDIR)/include + echo "/* Automatically generated file. Do not edit. */" >$(OBJDIR)/include/scratchbox2_version.h + echo '#define SCRATCHBOX2_VERSION "'`cat .version`'"' >>$(OBJDIR)/include/scratchbox2_version.h + echo '#define LIBSB2_SONAME "'$(LIBSB2_SONAME)'"' >>$(OBJDIR)/include/scratchbox2_version.h regular: .configure .version @$(MAKE) -f $(SRCDIR)/Makefile --include-dir=$(SRCDIR) SRCDIR=$(SRCDIR) do-all diff --git a/autogen.sh b/autogen.sh index 206c7b85..efa70cb9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,5 +3,4 @@ #automake_version=1.9 rm -rf configure autom4te.cache -autoreconf --verbose --force --install --make - +autoreconf --verbose --force --install diff --git a/llbuild/Makefile.include b/llbuild/Makefile.include index d00588e1..6dbc1aeb 100644 --- a/llbuild/Makefile.include +++ b/llbuild/Makefile.include @@ -1,4 +1,4 @@ -# ll build system +# ll build system -*- makefile -*- # # Copyright (C) 2006-2007 Lauri Leukkunen # @@ -41,15 +41,17 @@ endef define import_dir subdirs := subdirs-y := - objects := - objects-y := + objs := + objs-y := D := $(1) $(shell mkdir -p $(1)) - include $(1)/Makefile - dep_files := $$(wildcard $(1)/.*.d) - include $(dep_files) - all_objects := $$(all_objects) $$(patsubst %,$(1)/%,$$(objects)) - all_objects := $$(all_objects) $$(patsubst %,$(1)/%,$$(objects-y)) + include $(SRCDIR)/$(1)/Makefile + deps := $(join $(subst ./, $(D)/, $(dir $(objs))), $(patsubst %,.%.d,$(notdir $(objs)))) + objs-y := $(join $(subst ./, $(D)/, $(dir $(objs))), $(notdir $(objs))) + objs-all := $(objs-all) \ + $(patsubst %,$(OBJDIR)/%,$(objs-y)) + deps-all := $(deps-all) $(patsubst %,$(OBJDIR)/%,$(deps)) + include $(wildcard $(deps)) subdirs := $$(subdirs) $$(subdirs-y) tmp := $$(patsubst %,$(1)/%,$$(subdirs)) perkele := $$(foreach dir,$$(tmp),$$(eval $$(call import_dir,$$(dir)))) @@ -58,8 +60,9 @@ endef $(foreach dir,$(subdirs),$(eval $(call import_dir,$(dir)))) -all_objects += $(foreach t,$(extra_targets),$($(t))) +objs-all += $(foreach t,$(extra_targets),$($(t))) +CLEAN_FILES += $(deps-all) ifdef V Q = diff --git a/luaif/Makefile b/luaif/Makefile index c2c8a72d..f0d2a0a5 100644 --- a/luaif/Makefile +++ b/luaif/Makefile @@ -12,7 +12,7 @@ luaif/libluaif.a: override LDFLAGS := $(LDFLAGS) luaif/libluaif.a: override LIBS := $(LUA_LIBS) -luaif/sb_log.o: include/scratchbox2_version.h +luaif/sb_log.o: $(OBJDIR)/include/scratchbox2_version.h targets := $(targets) $(D)/libluaif.a diff --git a/preload/Makefile b/preload/Makefile index e3a17ee5..cedb3d4d 100644 --- a/preload/Makefile +++ b/preload/Makefile @@ -15,7 +15,7 @@ objs := wrappers.o privatewrappers.o \ ifeq ($(shell uname -s),Linux) LIBSB2_LDFLAGS = -Wl,-soname=$(LIBSB2_SONAME) \ - -Wl,--version-script=preload/export.map + -Wl,--version-script=$(OBJDIR)/preload/export.map # DO NOT add any libraries that depend on libpthread to # LIBSB2_LIBS or LIBS!! see the comments in luaif.c. @@ -42,31 +42,40 @@ $(D)/libsb2.$(SHLIBEXT): LIBS := -ldl $(LIBSB2_LIBS) targets := $(targets) $(D)/libsb2.$(SHLIBEXT) -$(D)/libsb2.o $(D)/sb_l10n.o: preload/exported.h -$(D)/exported.h $(D)/ldexportlist: preload/wrappers.c -$(D)/wrappers.c: preload/interface.master preload/gen-interface.pl +$(D)/libsb2.o $(D)/sb_l10n.o: $(OBJDIR)/preload/exported.h +preloader_generated_public := \ + $(OBJDIR)/$(D)/wrappers.c \ + $(OBJDIR)/$(D)/exported.h \ + $(OBJDIR)/$(D)/export.map \ + $(OBJDIR)/$(D)/libsb2_interface.7 + +$(preloader_generated_public): preload/interface.master \ + preload/gen-interface.pl $(MKOUTPUTDIR) $(P)PERL $(Q)$(SRCDIR)/preload/gen-interface.pl \ -n public \ - -W preload/wrappers.c \ - -E preload/exported.h \ - -M preload/export.map \ + -W $(OBJDIR)/preload/wrappers.c \ + -E $(OBJDIR)/preload/exported.h \ + -M $(OBJDIR)/preload/export.map \ -V $(PACKAGE_VERSION) \ - -m preload/libsb2_interface.7 \ + -m $(OBJDIR)/preload/libsb2_interface.7 \ <$(SRCDIR)/preload/interface.master -$(D)/privatewrappers.h: preload/privatewrappers.c -$(D)/privatewrappers.c: preload/interface.private preload/gen-interface.pl +preloader_generated_private := \ + $(OBJDIR)/$(D)/privatewrappers.h \ + $(OBJDIR)/$(D)/privatewrappers.c + +$(preloader_generated_private): preload/interface.private \ + preload/gen-interface.pl $(MKOUTPUTDIR) $(P)PERL $(Q)$(SRCDIR)/preload/gen-interface.pl \ -n private \ - -W preload/privatewrappers.c \ - -E preload/privatewrappers.h \ + -W $(OBJDIR)/preload/privatewrappers.c \ + -E $(OBJDIR)/preload/privatewrappers.h \ <$(SRCDIR)/preload/interface.private -generated := preload/wrappers.c preload/exported.h preload/ldexportlist -.PRECIOUS: $(generated) +.PRECIOUS: $(preloader_generated_public) $(preloader_generated_private) -CLEAN_FILES += $(generated) +CLEAN_FILES += $(preloader_generated_public) $(preloader_generated_private) diff --git a/preload/interface.master b/preload/interface.master index 66d097b2..4c5cab16 100644 --- a/preload/interface.master +++ b/preload/interface.master @@ -185,30 +185,30 @@ GATE: pid_t waitpid(pid_t pid, int *status, int options) GATE: int __open(const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map(pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map(pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int __open64(const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map(pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map(pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int open(const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map(pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map(pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ postprocess(pathname) \ create_nomap_nolog_version \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int open64(const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map(pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map(pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) -- open; variants witout varargs GATE: int __open_2(const char *pathname, int flags) : \ @@ -216,29 +216,29 @@ GATE: int __open_2(const char *pathname, int flags) : \ map(pathname) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int __open64_2(const char *pathname, int flags) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ map(pathname) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) -- openat: GATE: int openat(int dirfd, const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map_at(dirfd,pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map_at(dirfd,pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ create_nomap_nolog_version \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int openat64(int dirfd, const char *pathname, int flags, ...) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ - map_at(dirfd,pathname) optional_arg_is_create_mode(flags&O_CREAT) \ + map_at(dirfd,pathname) optional_arg_is_create_mode(__OPEN_NEEDS_MODE(flags)) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) -- openat; variants witout varargs GATE: int __openat_2(int dirfd, const char *pathname, int flags) : \ @@ -246,13 +246,13 @@ GATE: int __openat_2(int dirfd, const char *pathname, int flags) : \ map_at(dirfd,pathname) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) GATE: int __openat64_2(int dirfd, const char *pathname, int flags) : \ dont_resolve_final_symlink_if(flags&O_NOFOLLOW) \ map_at(dirfd,pathname) \ postprocess(pathname) \ check_and_fail_if_readonly(flags&OPEN_FLAGS_RW_MODE,pathname,-1,EROFS) \ - class(OPEN) conditionally_class(flags&O_CREAT,CREAT) + class(OPEN) conditionally_class(__OPEN_NEEDS_MODE(flags),CREAT) -- close: WRAP: int close(int fd) : \ diff --git a/rpm/scratchbox2.spec b/rpm/scratchbox2.spec index 1299ff3a..04835e62 100644 --- a/rpm/scratchbox2.spec +++ b/rpm/scratchbox2.spec @@ -42,8 +42,7 @@ Scratchbox2 man pages. ./autogen.sh %configure touch .configure -# Can't use %{?_smp_mflags} here: race condition in build system -%{__make} %{_make_output_sync} %{_make_verbose} +%make_build %install %__make install prefix=%{buildroot}/usr diff --git a/sblib/Makefile b/sblib/Makefile index b8836d52..aebcc820 100644 --- a/sblib/Makefile +++ b/sblib/Makefile @@ -12,7 +12,7 @@ sblib/libsblib.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall sblib/libsblib.a: override LDFLAGS := $(LDFLAGS) sblib/libsblib.a: override LIBS := -sblib/sb_log.o: include/scratchbox2_version.h +sblib/sb_log.o: $(OBJDIR)/include/scratchbox2_version.h targets := $(targets) $(D)/libsblib.a diff --git a/utils/sb2-ruletree.c b/utils/sb2-ruletree.c index d642503b..4899f2f0 100644 --- a/utils/sb2-ruletree.c +++ b/utils/sb2-ruletree.c @@ -47,10 +47,18 @@ void sblog_printf_line_to_logfile(const char *file, int line, va_end(ap); } -extern int open_nomap_nolog(const char *pathname, int flags, mode_t mode); +extern int open_nomap_nolog(const char *pathname, int flags, ...); -int open_nomap_nolog(const char *pathname, int flags, mode_t mode) +int open_nomap_nolog(const char *pathname, int flags, ...) { + mode_t mode = 0; + if(__OPEN_NEEDS_MODE(flags)) { + va_list arg; + va_start (arg, flags); + mode = va_arg (arg, int); + va_end (arg); + } + return open(pathname, flags, mode); }