-AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__
+AM_CFLAGS = -no-cpp-precomp -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__
+
+AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT)
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
-launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders
-launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib
+launchctl_CFLAGS = $(AM_CFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
+launchctl_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib
launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c
launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h
launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c
launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h
launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
mkdir -p $(DESTDIR)/Library/LaunchAgents
mkdir -p $(DESTDIR)/System/Library/LaunchAgents
mkdir -p $(DESTDIR)/System/Library/LaunchDaemons
mkdir -p $(DESTDIR)/Library/LaunchAgents
mkdir -p $(DESTDIR)/System/Library/LaunchAgents
mkdir -p $(DESTDIR)/System/Library/LaunchDaemons
cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h
cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h
cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h
cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h
cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h
cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h
cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h
cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h
cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h
cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h
cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h
cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h