# Makefile for Cygwin server
-# Copyright 2003 Red Hat, Inc.
+# Copyright 2003, 2006, 2007 Red Hat, Inc.
# This file is part of Cygwin.
exec_prefix:=@exec_prefix@
bindir:=@bindir@
-etcdir:=$(exec_prefix)/etc
+sbindir:=@sbindir@
+sysconfdir:=@sysconfdir@
program_transform_name:=@program_transform_name@
INSTALL:=@INSTALL@
INSTALL_PROGRAM:=@INSTALL_PROGRAM@
INSTALL_DATA:=@INSTALL_DATA@
-EXEEXT:=@EXEEXT@
-EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@
-
CC:=@CC@
CC_FOR_TARGET:=$(CC)
CXX:=@CXX@
CXX_FOR_TARGET:=$(CXX)
-
-CFLAGS:=@CFLAGS@ -I$(cygwin_source)
-CXXFLAGS:=@CXXFLAGS@ -I$(cygwin_source)
-override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0
+AR:=@AR@
include $(srcdir)/../Makefile.common
-OBJS:= cygserver.o client.o process.o shm.o transport.o transport_pipes.o \
- transport_sockets.o
+CFLAGS:=@CFLAGS@
+CXXFLAGS:=@CXXFLAGS@
+override CXXFLAGS+=-MMD -DHAVE_DECL_GETOPT=0 -D__OUTSIDE_CYGWIN__ -DSYSCONFDIR="\"$(sysconfdir)\""
+
+.SUFFIXES: .c .cc .a .o .d
+
+OBJS:= cygserver.o client.o process.o msg.o sem.o shm.o threaded_queue.o \
+ transport.o transport_pipes.o \
+ bsd_helper.o bsd_log.o bsd_mutex.o \
+ sysv_msg.o sysv_sem.o sysv_shm.o
+LIBOBJS:=${patsubst %.o,lib%.o,$(OBJS)}
-CYGWIN_OBJS:=$(cygwin_build)/smallprint.o $(cygwin_build)/version.o \
- $(cygwin_build)/wincap.o
+CYGWIN_OBJS:=$(cygwin_build)/smallprint.o $(cygwin_build)/strfuncs.o $(cygwin_build)/version.o
+
+CYGWIN_LIB:=$(cygwin_build)/libcygwin.a
all: cygserver.exe
-install: all
+install: all $(updir1)/mkinstalldirs cygserver.conf cygserver-config README
+ $(updir1)/mkinstalldirs $(sbindir)
+ $(updir1)/mkinstalldirs $(bindir)
+ $(updir1)/mkinstalldirs $(sysconfdir)/defaults/etc
+ $(updir1)/mkinstalldirs $(prefix)/share/doc/Cygwin
+ $(INSTALL_PROGRAM) cygserver.exe $(sbindir)/cygserver.exe
+ $(INSTALL_PROGRAM) $(srcdir)/cygserver-config $(bindir)/cygserver-config
+ $(INSTALL_DATA) $(srcdir)/cygserver.conf $(sysconfdir)/defaults/etc/cygserver.conf
+ $(INSTALL_DATA) $(srcdir)/README $(prefix)/share/doc/Cygwin/cygserver.README
+
+clean:
+ rm -f $(OBJS) ${patsubst %.o,%.d,$(OBJS)} cygserver.exe
+
+libclean:
+ rm -f $(LIBOBJS) ${patsubst %.o,%.d,$(LIBOBJS)} libcygserver.a
+
+fullclean: clean libclean
+
+cygserver.exe: $(CYGWIN_LIB) $(OBJS) $(CYGWIN_OBJS)
+ $(CXX) -o $@ ${wordlist 2,999,$^} -L$(cygwin_build) -lntdll
+
+$(cygwin_build)/%.o: $(cygwin_source)/%.cc
+ @$(MAKE) -C $(@D) $(@F)
+
+$(cygwin_build)/%.o: $(cygwin_source)/%.c
+ @$(MAKE) -C $(@D) $(@F)
+
+Makefile: Makefile.in configure
+
+lib%.o: %.cc
+ ${filter-out -D__OUTSIDE_CYGWIN__, $(COMPILE_CXX)} -I$(updir)/cygwin -o $(@D)/${basename $(@F)}$o $<
+
+libcygserver.a: $(LIBOBJS)
+ $(AR) crus $@ $?
-cygserver.exe: $(OBJS) $(CYGWIN_OBJS)
- $(CXX) -o $@ $^ -lstdc++
+deps:=${wildcard *.d}
+ifneq (,$(deps))
+include $(deps)
+endif