From f63e1913dabe03d035e796aec173f45783f1cfb0 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Wed, 15 Jan 2003 20:18:12 +0000 Subject: [PATCH] 2003-01-15 Casper S. Hornstrup * tools/rtouch.c: New file. * rules.mak (ROS_USE_PCH): Default to no. (RTOUCH): Define. * tools/Makefile: Add rtouch utility. * tools/helper.mk: Support precompiled headers. svn path=/trunk/; revision=4006 --- reactos/ChangeLog | 8 +++++ reactos/rules.mak | 6 ++++ reactos/tools/Makefile | 13 +++++++- reactos/tools/helper.mk | 35 ++++++++++++++++++--- reactos/tools/rtouch.c | 68 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 5 deletions(-) create mode 100755 reactos/tools/rtouch.c diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 9a2969219b5..79775791a3a 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,11 @@ +2003-01-15 Casper S. Hornstrup + + * tools/rtouch.c: New file. + * rules.mak (ROS_USE_PCH): Default to no. + (RTOUCH): Define. + * tools/Makefile: Add rtouch utility. + * tools/helper.mk: Support precompiled headers. + 2003-01-15 Casper S. Hornstrup * ntoskrnl/dbg/profile.c: New file. diff --git a/reactos/rules.mak b/reactos/rules.mak index fd6874b93cf..23ab1d655ed 100644 --- a/reactos/rules.mak +++ b/reactos/rules.mak @@ -8,6 +8,11 @@ ifeq ($(HOST),) HOST = mingw32-windows endif +# Default to no PCH support +ifeq ($(ROS_USE_PCH),) +ROS_USE_PCH = no +endif + # uncomment if you use bochs and it displays only 30 rows # BOCHS_30ROWS = yes @@ -77,6 +82,7 @@ RM = $(TOOLS_PATH)/rdel RMDIR = $(TOOLS_PATH)/rrmdir RMKDIR = $(TOOLS_PATH)/rmkdir RSYM = $(TOOLS_PATH)/rsym +RTOUCH = $(TOOLS_PATH)/rtouch MC = $(TOOLS_PATH)/wmc/wmc diff --git a/reactos/tools/Makefile b/reactos/tools/Makefile index 5f7f8284adf..cee144c5c9f 100644 --- a/reactos/tools/Makefile +++ b/reactos/tools/Makefile @@ -7,7 +7,8 @@ TOOLS = \ rdel$(EXE_POSTFIX) \ rmkdir$(EXE_POSTFIX) \ rrmdir$(EXE_POSTFIX) \ - rsym$(EXE_POSTFIX) + rsym$(EXE_POSTFIX) \ + rtouch$(EXE_POSTFIX) CLEAN_FILES = $(TOOLS) @@ -59,6 +60,16 @@ rsym$(EXE_POSTFIX): rsym.c $(HOST_CC) $(CFLAGS) -DDOS_PATHS rsym.c -o rsym$(EXE_POSTFIX) endif +ifeq ($(HOST),mingw32-linux) +rtouch$(EXE_POSTFIX): rtouch.c + $(HOST_CC) $(CFLAGS) -DUNIX_PATHS rtouch.c -o rtouch$(EXE_POSTFIX) +endif +ifeq ($(HOST),mingw32-windows) +rtouch$(EXE_POSTFIX): rtouch.c + $(HOST_CC) $(CFLAGS) -DDOS_PATHS rtouch.c -o rtouch$(EXE_POSTFIX) +endif + + wmc_directory_target: make -C wmc wmc$(EXE_POSTFIX) diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index 8209ce2fff7..528a8963dc3 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -1,4 +1,4 @@ -# $Id: helper.mk,v 1.25 2003/01/07 17:39:58 robd Exp $ +# $Id: helper.mk,v 1.26 2003/01/15 20:18:12 chorns Exp $ # # Helper makefile for ReactOS modules # Variables this makefile accepts: @@ -39,6 +39,7 @@ # $TARGET_NORC = Do not include standard resource file (no,yes) (optional) # $TARGET_LIBPATH = Destination path for import libraries (optional) # $TARGET_INSTALLDIR = Destination path when installed (optional) +# $TARGET_PCH = Filename of header to use to generate a PCH if supported by the compiler (optional) # $WINE_MODE = Compile using WINE headers (no,yes) (optional) # $WINE_RC = Name of .rc file for WINE modules (optional) @@ -591,7 +592,7 @@ endif MK_CLEANFILES := $(filter %.o,$(MK_OBJECTS)) clean: - - $(RM) *.o $(MK_BASENAME).sym $(MK_BASENAME).a $(TARGET_PATH)/$(MK_RES_BASE).coff \ + - $(RM) *.o depend.d *.pch $(MK_BASENAME).sym $(MK_BASENAME).a $(TARGET_PATH)/$(MK_RES_BASE).coff \ $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(MK_CLEANFILES) \ junk.tmp base.tmp temp.exp \ $(TARGET_CLEAN) @@ -626,14 +627,40 @@ $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME): $(MK_FULLNAME) $(CP) $(MK_FULLNAME) $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME) $(CP) $(MK_BASENAME).sym $(DIST_DIR)/symbols/$(MK_BASENAME).sym - endif # MK_IMPLIBONLY .phony: all depends implib clean install dist depends -%.o: %.c +# Precompiled header support +# When using PCHs, use dependency tracking to keep the .pch files up-to-date. + +MK_PCHNAME = +ifeq ($(ROS_USE_PCH),yes) +ifneq ($(TARGET_PCH),) +MK_PCHNAME = $(TARGET_PCH).pch + +# GCC generates wrong dependencies for header files. +MK_PCHFAKE = $(TARGET_PCH:.h=.o) +$(MK_PCHFAKE): + - $(RTOUCH) $(MK_PCHFAKE) + +$(MK_PCHNAME): depend.d + - $(RTOUCH) $(MK_PCHNAME) + - $(CC) $(TARGET_CFLAGS) $(TARGET_PCH) + +depend.d: $(MK_PCHFAKE) + - $(RTOUCH) depend.d + - $(CC) $(TARGET_CFLAGS) $(TARGET_PCH) -M -MF depend.d + +include depend.d + +endif # TARGET_PCH +endif # ROS_USE_PCH + + +%.o: %.c $(MK_PCHNAME) $(CC) $(TARGET_CFLAGS) -c $< -o $@ %.o: %.cc $(CC) $(TARGET_CPPFLAGS) -c $< -o $@ diff --git a/reactos/tools/rtouch.c b/reactos/tools/rtouch.c new file mode 100755 index 00000000000..3ab718bf886 --- /dev/null +++ b/reactos/tools/rtouch.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include + +char* convert_path(char* origpath) +{ + char* newpath; + int i; + + newpath = (char *)strdup(origpath); + + i = 0; + while (newpath[i] != 0) + { +#ifdef UNIX_PATHS + if (newpath[i] == '\\') + { + newpath[i] = '/'; + } +#else +#ifdef DOS_PATHS + if (newpath[i] == '/') + { + newpath[i] = '\\'; + } +#endif +#endif + i++; + } + return(newpath); +} + +int main(int argc, char* argv[]) +{ + char* path; + FILE* file; + time_t now; + struct utimbuf fnow; + + if (argc != 2) + { + fprintf(stderr, "Wrong number of arguments.\n"); + exit(1); + } + + path = convert_path(argv[1]); + file = (FILE *)open(path, S_IWRITE); + if (file == (void*)-1) + { + file = (FILE *)open(path, S_IWRITE | O_CREAT); + if (file == (void*)-1) + { + fprintf(stderr, "Cannot create file.\n"); + exit(1); + } + } + + close(file); + + now = time(); + fnow.actime = now; + fnow.modtime = now; + (int) utime(path, &fnow); + + exit(0); +}