diff options
Diffstat (limited to 'utils')
34 files changed, 555 insertions, 410 deletions
diff --git a/utils/genapply/Makefile b/utils/genapply/Makefile index 186eb0e034..06c44cf2a8 100644 --- a/utils/genapply/Makefile +++ b/utils/genapply/Makefile @@ -1,29 +1,3 @@ -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -HS_PROG = $(GHC_GENAPPLY_PGM) - -# genapply is needed to boot in rts/... -ifneq "$(BootingFromHc)" "YES" -boot :: all -endif - -ifeq "$(GhcUnregisterised)" "YES" -SRC_HC_OPTS += -DNO_REGS -endif - -ifeq "$(ghc_ge_607)" "YES" -SRC_HC_OPTS += -package pretty -endif - -# Try to get dependencies right... -SRC_HC_OPTS += -fforce-recomp - -GenApply.o : $(GHC_INCLUDE_DIR)/ghcconfig.h -GenApply.o : $(GHC_INCLUDE_DIR)/MachRegs.h -GenApply.o : $(GHC_INCLUDE_DIR)/Constants.h - -binary-dist: - @: - -include $(TOP)/mk/target.mk +dir = utils/genapply +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/genapply/ghc.mk b/utils/genapply/ghc.mk new file mode 100644 index 0000000000..94fb45639c --- /dev/null +++ b/utils/genapply/ghc.mk @@ -0,0 +1,16 @@ +utils/genapply_dist_MODULES = GenApply +utils/genapply_dist_PROG = $(GHC_GENAPPLY_PGM) + +ifeq "$(ghc_ge_607)" "YES" +utils/genapply_HC_OPTS += -package pretty +endif + +ifeq "$(GhcUnregisterised)" "YES" +utils/genapply_HC_OPTS += -DNO_REGS +endif + +utils/genapply/GenApply.hs : $(GHC_INCLUDE_DIR)/ghcconfig.h +utils/genapply/GenApply.hs : $(GHC_INCLUDE_DIR)/MachRegs.h +utils/genapply/GenApply.hs : $(GHC_INCLUDE_DIR)/Constants.h + +$(eval $(call build-prog,utils/genapply,dist,0)) diff --git a/utils/genprimopcode/Makefile b/utils/genprimopcode/Makefile index ed011eb0c2..8849708790 100644 --- a/utils/genprimopcode/Makefile +++ b/utils/genprimopcode/Makefile @@ -1,10 +1,3 @@ -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -HS_PROG = genprimopcode - -binary-dist: - @: - -include $(TOP)/mk/target.mk - +dir = utils/genprimopcode +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/genprimopcode/ghc.mk b/utils/genprimopcode/ghc.mk new file mode 100644 index 0000000000..74ac4232e6 --- /dev/null +++ b/utils/genprimopcode/ghc.mk @@ -0,0 +1,4 @@ +utils/genprimopcode_dist_MODULES = Lexer Main ParserM Parser Syntax +utils/genprimopcode_dist_PROG = $(GHC_GENPRIMOP_PGM) + +$(eval $(call build-prog,utils/genprimopcode,dist,0)) diff --git a/utils/ghc-cabal/ghc-cabal.hs b/utils/ghc-cabal/ghc-cabal.hs new file mode 100644 index 0000000000..c806d3cf16 --- /dev/null +++ b/utils/ghc-cabal/ghc-cabal.hs @@ -0,0 +1,246 @@ + +module Main (main) where + +import qualified Distribution.ModuleName as ModuleName +import Distribution.PackageDescription +import Distribution.PackageDescription.Configuration +import Distribution.PackageDescription.Parse +import Distribution.Simple +import Distribution.Simple.Configure +import Distribution.Simple.LocalBuildInfo +import Distribution.Simple.Program +import Distribution.Simple.Utils (defaultPackageDesc) +import Distribution.Simple.Build (writeAutogenFiles) +import Distribution.Simple.Register (writeInstalledConfig) +import Distribution.Text +import Distribution.Verbosity +import qualified Distribution.InstalledPackageInfo as Installed + ( InstalledPackageInfo_(..) ) +import qualified Distribution.Simple.PackageIndex as PackageIndex + ( topologicalOrder, lookupPackageName, insert ) + +import Control.Monad +import Data.Maybe +import System.IO +import System.Directory +import System.Environment +import System.Exit +import System.FilePath + +main :: IO () +main = do args <- getArgs + case args of + "haddock" : distDir : dir : args' -> + runHaddock distDir dir args' + "install" : ghcpkg : ghcpkgconfig : directory : distDir + : myDestDir : myPrefix : myLibdir : myDocdir : args' -> + doInstall ghcpkg ghcpkgconfig directory distDir + myDestDir myPrefix myLibdir myDocdir args' + "configure" : args' -> case break (== "--") args' of + (config_args, "--" : distdir : directories) -> + mapM_ (generate config_args distdir) directories + _ -> die syntax_error + _ -> die syntax_error + +syntax_error :: [String] +syntax_error = + ["syntax: ghc-cabal configure <configure-args> -- <distdir> <directory>...", + " ghc-cabal install <ghc-pkg> <directory> <distdir> <destdir> <prefix> <args>...", + " ghc-cabal haddock <distdir> <directory> <args>..."] + +die :: [String] -> IO () +die errs = do mapM_ (hPutStrLn stderr) errs + exitWith (ExitFailure 1) + +-- XXX Should use bracket +withCurrentDirectory :: FilePath -> IO a -> IO a +withCurrentDirectory directory io + = do curDirectory <- getCurrentDirectory + setCurrentDirectory directory + r <- io + setCurrentDirectory curDirectory + return r + +-- We need to use the autoconfUserHooks, as the packages that use +-- configure can create a .buildinfo file, and we need any info that +-- ends up in it. +userHooks :: UserHooks +userHooks = autoconfUserHooks + +runHaddock :: FilePath -> FilePath -> [String] -> IO () +runHaddock distdir directory args + = withCurrentDirectory directory + $ defaultMainWithHooksArgs hooks ("haddock" : "--builddir" : distdir : args) + where + hooks = userHooks { + haddockHook = modHook (haddockHook userHooks) + } + modHook f pd lbi us flags + | packageName pd == PackageName "ghc-prim" + = let pd' = case library pd of + Just lib -> + let ghcPrim = fromJust (simpleParse "GHC.Prim") + ems = filter (ghcPrim /=) + (exposedModules lib) + lib' = lib { exposedModules = ems } + in pd { library = Just lib' } + Nothing -> + error "Expected a library, but none found" + pc = withPrograms lbi + pc' = userSpecifyArgs "haddock" + ["dist-install/build/autogen/GHC/Prim.hs"] pc + lbi' = lbi { withPrograms = pc' } + in f pd' lbi' us flags + | otherwise + = f pd lbi us flags + +doInstall :: FilePath -> FilePath -> FilePath -> FilePath -> FilePath + -> FilePath -> FilePath -> FilePath -> [String] -> IO () +doInstall ghcpkg ghcpkgconf directory distDir myDestDir myPrefix myLibdir myDocdir args + = withCurrentDirectory directory $ do + defaultMainWithHooksArgs hooks (["copy", "--builddir", distDir] + ++ (if null myDestDir then [] + else ["--destdir", myDestDir]) + ++ args) + defaultMainWithHooksArgs hooks ("register" : "--builddir" : distDir : args) + where + hooks = userHooks { + copyHook = modHook (copyHook userHooks), + regHook = modHook (regHook userHooks) + } + + modHook f pd lbi us flags + = let + pd' + | packageName pd == PackageName "ghc-prim" = + case library pd of + Just lib -> + let ghcPrim = fromJust (simpleParse "GHC.Prim") + ems = filter (ghcPrim /=) (exposedModules lib) + lib' = lib { exposedModules = ems } + in pd { library = Just lib' } + Nothing -> + error "Expected a library, but none found" + | otherwise = pd + idts = installDirTemplates lbi + idts' = idts { prefix = toPathTemplate myPrefix, + libdir = toPathTemplate myLibdir, + libsubdir = toPathTemplate "$pkgid", + docdir = toPathTemplate (myDocdir </> "$pkgid"), + htmldir = toPathTemplate "$docdir" } + progs = withPrograms lbi + prog = ConfiguredProgram { + programId = programName ghcPkgProgram, + programVersion = Nothing, + programArgs = ["--global-conf", ghcpkgconf] + ++ if not (null myDestDir) + then ["--force"] + else [], + programLocation = UserSpecified ghcpkg + } + progs' = updateProgram prog progs + lbi' = lbi { + installDirTemplates = idts', + withPrograms = progs' + } + in f pd' lbi' us flags + +generate :: [String] -> FilePath -> FilePath -> IO () +generate config_args distdir directory + = withCurrentDirectory directory + $ do let verbosity = verbose + gpdFile <- defaultPackageDesc verbosity + gpd <- readPackageDescription verbosity gpdFile + + -- XXX We shouldn't just configure with the default flags + -- XXX And this, and thus the "getPersistBuildConfig distdir" below, + -- aren't going to work when the deps aren't built yet + withArgs (["configure", "--distdir", distdir] ++ config_args) + (case buildType (flattenPackageDescription gpd) of + Just Configure -> defaultMainWithHooks autoconfUserHooks + _other -> defaultMain) + -- not quite right, but good enough for us + + lbi <- getPersistBuildConfig distdir + let pd0 = localPkgDescr lbi + + hooked_bi <- + if (buildType pd0 == Just Configure) + then do + maybe_infoFile <- defaultHookedPackageDesc + case maybe_infoFile of + Nothing -> return emptyHookedBuildInfo + Just infoFile -> readHookedBuildInfo verbosity infoFile + else + return emptyHookedBuildInfo + + let pd = updatePackageDescription hooked_bi pd0 + + -- generate Paths_<pkg>.hs and cabal-macros.h + writeAutogenFiles verbosity pd lbi + + -- generate inplace-pkg-config + when (isJust $ library pd) $ + writeInstalledConfig distdir pd lbi True Nothing + + let + libBiModules lib = (libBuildInfo lib, libModules pd) + exeBiModules exe = (buildInfo exe, ModuleName.main : exeModules pd) + biModuless = (maybeToList $ fmap libBiModules $ library pd) + ++ (map exeBiModules $ executables pd) + buildableBiModuless = filter isBuildable biModuless + where isBuildable (bi', _) = buildable bi' + (bi, modules) = case buildableBiModuless of + [] -> error "No buildable component found" + [biModules] -> biModules + _ -> error ("XXX ghc-cabal can't handle " ++ + "more than one buildinfo yet") + -- XXX Another Just... + Just ghcProg = lookupProgram ghcProgram (withPrograms lbi) + + dep_pkgs = PackageIndex.topologicalOrder (packageHacks (installedPkgs lbi)) + forDeps f = concatMap f dep_pkgs + + -- copied from Distribution.Simple.PreProcess.ppHsc2Hs + packageHacks = case compilerFlavor (compiler lbi) of + GHC -> hackRtsPackage + _ -> id + -- We don't link in the actual Haskell libraries of our + -- dependencies, so the -u flags in the ldOptions of the rts + -- package mean linking fails on OS X (it's ld is a tad + -- stricter than gnu ld). Thus we remove the ldOptions for + -- GHC's rts package: + hackRtsPackage index = + case PackageIndex.lookupPackageName index (PackageName "rts") of + [rts] -> PackageIndex.insert rts { Installed.ldOptions = [] } index + _ -> error "No (or multiple) ghc rts package is registered!!" + + let variablePrefix = directory ++ '_':distdir + let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)), + variablePrefix ++ "_MODULES = " ++ unwords (map display modules), + variablePrefix ++ "_HS_SRC_DIRS = " ++ unwords (hsSourceDirs bi), + variablePrefix ++ "_DEPS = " ++ unwords (map display (packageDeps lbi)), + variablePrefix ++ "_DEP_NAMES = " ++ unwords (map (display . packageName) (packageDeps lbi)), + variablePrefix ++ "_INCLUDE_DIRS = " ++ unwords (includeDirs bi), + variablePrefix ++ "_INCLUDES = " ++ unwords (includes bi), + variablePrefix ++ "_INSTALL_INCLUDES = " ++ unwords (installIncludes bi), + variablePrefix ++ "_EXTRA_LIBRARIES = " ++ unwords (extraLibs bi), + variablePrefix ++ "_EXTRA_LIBDIRS = " ++ unwords (extraLibDirs bi), + variablePrefix ++ "_C_SRCS = " ++ unwords (cSources bi), + -- XXX This includes things it shouldn't, like: + -- -odir dist-bootstrapping/build + variablePrefix ++ "_HC_OPTS = " ++ escape (unwords + (programArgs ghcProg + ++ hcOptions GHC bi + ++ extensionsToFlags (compiler lbi) (extensions bi))), + variablePrefix ++ "_CC_OPTS = " ++ unwords (ccOptions bi), + variablePrefix ++ "_CPP_OPTS = " ++ unwords (cppOptions bi), + variablePrefix ++ "_LD_OPTS = " ++ unwords (ldOptions bi), + variablePrefix ++ "_DEP_INCLUDE_DIRS = " ++ unwords (forDeps Installed.includeDirs), + variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions), + variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (forDeps Installed.libraryDirs), + variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries), + variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions)] + writeFile (distdir ++ "/package-data.mk") $ unlines xs + where + escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) [] diff --git a/utils/ghc-cabal/ghc.mk b/utils/ghc-cabal/ghc.mk new file mode 100644 index 0000000000..c0fd0f336d --- /dev/null +++ b/utils/ghc-cabal/ghc.mk @@ -0,0 +1,54 @@ +# ----------------------------------------------------------------------------- +# Bootstrapping ghc-cabal + +# Euch, hideous hack: +# XXX This should be in a different Makefile +CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal.cabal | sed "s/^Version: //") +CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION)) +CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)" + +$(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext) + $(MKDIRHIER) $(dir $@) + $(CP) $< $@ + +$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs $(MKDIRHIER) + $(MKDIRHIER) bootstrapping + $(MKDIRHIER) $(dir $@) + $(GHC) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \ + -Wall $(WERROR) \ + -DCABAL_VERSION=$(CABAL_VERSION) \ + -odir bootstrapping \ + -hidir bootstrapping \ + -ilibraries/Cabal \ + -ilibraries/filepath \ + -ilibraries/hpc + touch $@ + +# touch is required, because otherwise if mkdirhier is newer, we +# repeatedly rebuild ghc-cabal. + +$(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\ + $(GHC_CABAL_DIR)/dist bootstrapping)) + +$(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE))) + +# ----------------------------------------------------------------------------- +# dummy-ghc + +# This is a tiny program to fool Cabal's configure that we have a +# stage1 GHC, which lets us configure all the packages before we've +# build stage1. + +$(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc +$(GHC_CABAL_DIR)_dist-dummy-ghc_PROG = dummy-ghc$(exeext) + +$(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER) + $(MKDIRHIER) $(dir $@) + echo "import System.Environment; import System.Cmd; import System.Exit" >$@ + echo "main = do args <- getArgs; if args == [\"--numeric-version\"] then putStrLn \"$(ProjectVersion)\" else do e <- rawSystem \"$(GHC_STAGE0)\" args; exitWith e" >>$@ + +# We don't build dummy-ghc with Cabal, so we need to pass -package +# flags manually +utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process +$(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0)) + diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 3d1c8059c7..b1aaaba7b0 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -378,19 +378,14 @@ getPkgDatabases modify my_flags = do let err_msg = "missing --global-conf option, location of global package.conf unknown\n" global_conf <- case [ f | FlagGlobalConfig f <- my_flags ] of - [] -> do mb_dir <- getExecDir "/bin/ghc-pkg.exe" + [] -> do mb_dir <- getLibDir case mb_dir of Nothing -> die err_msg Just dir -> - do let path1 = dir </> "package.conf" - path2 = dir </> ".." </> ".." </> ".." - </> "inplace-datadir" - </> "package.conf" - exists1 <- doesFileExist path1 - exists2 <- doesFileExist path2 - if exists1 then return path1 - else if exists2 then return path2 - else die "Can't find package.conf" + do let path = dir </> "package.conf" + exists <- doesFileExist path + unless exists $ die "Can't find package.conf" + return path fs -> return (last fs) let global_conf_dir = global_conf ++ ".d" @@ -1053,7 +1048,7 @@ checkGHCiLib dirs batch_lib_dir batch_lib_file lib auto_build | auto_build = autoBuildGHCiLib batch_lib_dir batch_lib_file ghci_lib_file | otherwise = do m <- doesFileExistOnPath ghci_lib_file dirs - when (isNothing m) $ + when (isNothing m && ghci_lib_file /= "HSrts.o") $ hPutStrLn stderr ("warning: can't find GHCi lib " ++ ghci_lib_file) where ghci_lib_file = lib <.> "o" @@ -1069,7 +1064,7 @@ autoBuildGHCiLib dir batch_file ghci_file = do #if defined(darwin_HOST_OS) r <- rawSystem "ld" ["-r","-x","-o",ghci_lib_file,"-all_load",batch_lib_file] #elif defined(mingw32_HOST_OS) - execDir <- getExecDir "/bin/ghc-pkg.exe" + execDir <- getLibDir r <- rawSystem (maybe "" (++"/gcc-lib/") execDir++"ld") ["-r","-x","-o",ghci_lib_file,"--whole-archive",batch_lib_file] #else r <- rawSystem "ld" ["-r","-x","-o",ghci_lib_file,"--whole-archive",batch_lib_file] @@ -1184,26 +1179,34 @@ subst a b ls = map (\ x -> if x == a then b else x) ls unDosifyPath :: FilePath -> FilePath unDosifyPath xs = subst '\\' '/' xs -getExecDir :: String -> IO (Maybe String) +getLibDir :: IO (Maybe String) +getLibDir = fmap (fmap (</> "lib")) $ getExecDir "/bin/ghc-pkg.exe" + -- (getExecDir cmd) returns the directory in which the current -- executable, which should be called 'cmd', is running -- So if the full path is /a/b/c/d/e, and you pass "d/e" as cmd, -- you'll get "/a/b/c" back as the result -getExecDir cmd - = allocaArray len $ \buf -> do - ret <- getModuleFileName nullPtr buf len - if ret == 0 then return Nothing - else do s <- peekCString buf - return (Just (reverse (drop (length cmd) - (reverse (unDosifyPath s))))) - where - len = 2048::Int -- Plenty, PATH_MAX is 512 under Win32. +getExecDir :: String -> IO (Maybe String) +getExecDir cmd = + getExecPath >>= maybe (return Nothing) removeCmdSuffix + where unDosifyPath = subst '\\' '/' + initN n = reverse . drop n . reverse + removeCmdSuffix = return . Just . initN (length cmd) . unDosifyPath + +getExecPath :: IO (Maybe String) +getExecPath = + allocaArray len $ \buf -> do + ret <- getModuleFileName nullPtr buf len + if ret == 0 then return Nothing + else liftM Just $ peekCString buf + where len = 2048 -- Plenty, PATH_MAX is 512 under Win32. + +foreign import stdcall unsafe "GetModuleFileNameA" + getModuleFileName :: Ptr () -> CString -> Int -> IO Int32 -foreign import stdcall unsafe "GetModuleFileNameA" - getModuleFileName :: Ptr () -> CString -> Int -> IO Int32 #else -getExecDir :: String -> IO (Maybe String) -getExecDir _ = return Nothing +getLibDir :: IO (Maybe String) +getLibDir = return Nothing #endif ----------------------------------------- diff --git a/utils/ghc-pkg/Makefile b/utils/ghc-pkg/Makefile index 632e02c1d5..c45176561c 100644 --- a/utils/ghc-pkg/Makefile +++ b/utils/ghc-pkg/Makefile @@ -1,21 +1,3 @@ - -TOP=../.. -ENABLE_SHELL_WRAPPERS = YES -EXTRA_CLEAN = Version.hs -EXTRA_INPLACE_CONFIGURE_FLAGS = $(INPLACE_GHC_DATADIR_CONFIGURE_FLAGS) -EXTRA_STAGE2_CONFIGURE_FLAGS = --datasubdir=. - -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal.mk - -with-bootstrapping-compiler: Version.hs -with-stage-2: Version.hs - -Version.hs: Makefile $(TOP)/mk/config.mk - $(RM) -f Version.hs - echo "module Version where" >> Version.hs - echo "version, targetOS, targetARCH :: String" >> Version.hs - echo "version = \"$(ProjectVersion)\"" >> Version.hs - echo "targetOS = \"$(TargetOS_CPP)\"" >> Version.hs - echo "targetARCH = \"$(TargetArch_CPP)\"" >> Version.hs - +dir = utils/ghc-pkg +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk new file mode 100644 index 0000000000..388af0d5b9 --- /dev/null +++ b/utils/ghc-pkg/ghc.mk @@ -0,0 +1,69 @@ +# ----------------------------------------------------------------------------- +# Bootstrapping ghc-pkg + +utils/ghc-pkg_dist_PROG = ghc-pkg + +$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext) $(MKDIRHIER) + $(MKDIRHIER) $(dir $(INPLACE_PACKAGE_CONF)) + echo "[]" > $(INPLACE_PACKAGE_CONF) +ifeq "$(Windows)" "YES" + cp $< $@ +else + $(RM) $@ + echo "#!/bin/sh" >>$@ + echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@ + echo '$(TOP)/utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG) --global-conf $$PKGCONF $${1+"$$@"}' >> $@ + chmod +x $@ +endif + +# depend on ghc-cabal, otherwise we build Cabal twice when building in parallel +utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/Main.hs utils/ghc-pkg/Version.hs $(GHC_CABAL_INPLACE) $(MKDIRHIER) + $(MKDIRHIER) bootstrapping + $(MKDIRHIER) utils/ghc-pkg/dist/build + $(GHC) --make utils/ghc-pkg/Main.hs -o $@ \ + -Wall \ + -DCABAL_VERSION=$(CABAL_VERSION) \ + -odir bootstrapping \ + -hidir bootstrapping \ + -iutils/ghc-pkg \ + -XCPP -XExistentialQuantification -XDeriveDataTypeable \ + -ilibraries/Cabal \ + -ilibraries/filepath \ + -ilibraries/extensible-exceptions \ + -ilibraries/hpc + +utils/ghc-pkg/Version.hs: mk/config.mk + $(RM) -f $@ + echo "module Version where" >> $@ + echo "version, targetOS, targetARCH :: String" >> $@ + echo "version = \"$(ProjectVersion)\"" >> $@ + echo "targetOS = \"$(TargetOS_CPP)\"" >> $@ + echo "targetARCH = \"$(TargetArch_CPP)\"" >> $@ + +$(eval $(call clean-target,utils/ghc-pkg,dist,\ + utils/ghc-pkg/dist \ + utils/ghc-pkg/Version.hs)) + +# ----------------------------------------------------------------------------- +# Building ghc-pkg with stage 1 + +utils/ghc-pkg_dist-install_PROG = ghc-pkg +utils/ghc-pkg_dist-install_MODULES = Main Version +utils/ghc-pkg_dist-install_DEPS = Cabal +utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES +utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER = YES +utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion) +utils/ghc-pkg_dist-install_INSTALL_INPLACE = NO + +$(eval $(call build-prog,utils/ghc-pkg,dist-install,1)) + +ifeq "$(Windows)" "NO" +install: install_utils/ghc-pkg_link + +.PNONY: install_utils/ghc-pkg_link +install_utils/ghc-pkg_link: + $(MKDIRHIER) $(DESTDIR)$(bindir) + $(RM) -f $(DESTDIR)$(bindir)/ghc-pkg + $(LN_S) ghc-pkg-$(ProjectVersion) $(DESTDIR)$(bindir)/ghc-pkg +endif + diff --git a/utils/hasktags/Makefile b/utils/hasktags/Makefile index 0f34de9174..64905b050a 100644 --- a/utils/hasktags/Makefile +++ b/utils/hasktags/Makefile @@ -1,5 +1,3 @@ - -TOP=../.. -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal.mk - +dir = utils/hasktags +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/hasktags/ghc.mk b/utils/hasktags/ghc.mk new file mode 100644 index 0000000000..38ed434228 --- /dev/null +++ b/utils/hasktags/ghc.mk @@ -0,0 +1,10 @@ +utils/hasktags_dist_MODULES = Main +utils/hasktags_dist_PROG = hasktags$(exeext) +utils/hasktags_dist_INSTALL = YES + +utils/hasktags/dist/build/Main.hs : utils/hasktags/HaskTags.hs $(MKDIRHIER) + $(MKDIRHIER) $(dir $@) + $(CP) $< $@ + +$(eval $(call build-prog,utils/hasktags,dist,1)) + diff --git a/utils/hp2ps/Main.h b/utils/hp2ps/Main.h index 81c62dc891..0d0d75f847 100644 --- a/utils/hp2ps/Main.h +++ b/utils/hp2ps/Main.h @@ -1,7 +1,7 @@ #ifndef MAIN_H #define MAIN_H -#include "../includes/ghcconfig.h" +#include "ghcconfig.h" #include <stdio.h> #ifdef __STDC__ diff --git a/utils/hp2ps/Makefile b/utils/hp2ps/Makefile index 93aa856ffc..ed3dff8b21 100644 --- a/utils/hp2ps/Makefile +++ b/utils/hp2ps/Makefile @@ -1,20 +1,3 @@ -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS) -SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS) - -C_PROG = hp2ps - -SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall - -INSTALL_PROGS += $(C_PROG) - -LIBS = $(LIBM) - -CLEAN_FILES += $(C_OBJS) $(C_PROG) - -BINDIST_EXTRAS += $(C_PROG) -include $(TOP)/mk/bindist.mk - -include $(TOP)/mk/target.mk +dir = utils/hp2ps +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/hp2ps/ghc.mk b/utils/hp2ps/ghc.mk new file mode 100644 index 0000000000..75964e1e39 --- /dev/null +++ b/utils/hp2ps/ghc.mk @@ -0,0 +1,10 @@ +utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \ + Reorder.c TopTwenty.c AuxFile.c Deviation.c \ + HpFile.c Marks.c Scale.c TraceElement.c \ + Axes.c Dimensions.c Key.c PsFile.c Shade.c \ + Utilities.c +utils/hp2ps_dist_PROG = hp2ps$(exeext) +utils/hp2ps_dist_INSTALL = YES + +$(eval $(call build-prog,utils/hp2ps,dist,0)) + diff --git a/utils/hpc/Hpc.hs b/utils/hpc/Main.hs index da859d0345..da859d0345 100644 --- a/utils/hpc/Hpc.hs +++ b/utils/hpc/Main.hs diff --git a/utils/hpc/Makefile b/utils/hpc/Makefile index 0f34de9174..a8458d2ee6 100644 --- a/utils/hpc/Makefile +++ b/utils/hpc/Makefile @@ -1,5 +1,3 @@ - -TOP=../.. -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal.mk - +dir = utils/hpc +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/hpc/ghc.mk b/utils/hpc/ghc.mk new file mode 100644 index 0000000000..0e0f91cd94 --- /dev/null +++ b/utils/hpc/ghc.mk @@ -0,0 +1,7 @@ +utils/hpc_dist_MODULES = Main HpcCombine HpcDraft HpcFlags HpcLexer HpcMap \ + HpcMarkup HpcOverlay HpcParser HpcReport HpcSet \ + HpcShowTix HpcUtils +utils/hpc_dist_HC_OPTS = -cpp -package hpc +utils/hpc_dist_INSTALL = YES +utils/hpc_dist_PROG = hpc$(exeext) +$(eval $(call build-prog,utils/hpc,dist,1)) diff --git a/utils/installPackage/Makefile b/utils/installPackage/Makefile deleted file mode 100644 index 758442dc85..0000000000 --- a/utils/installPackage/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -TOP=../.. -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal.mk - -# If the bootstrapping compiler already has a newer version of Cabal -# than the in-tree Cabal, then we need to forcibly use the in-tree one. -# Otherwise we use one Cabal for some things and the other Cabal for -# other things, and Cabal (rightly) complains about the version -# mismatch. -EXTRA_INPLACE_CONFIGURE_FLAGS += $(CABAL_CONSTRAINT) -EXTRA_STAGE2_CONFIGURE_FLAGS += $(CABAL_CONSTRAINT) - diff --git a/utils/installPackage/installPackage.cabal b/utils/installPackage/installPackage.cabal deleted file mode 100644 index ab078200d5..0000000000 --- a/utils/installPackage/installPackage.cabal +++ /dev/null @@ -1,28 +0,0 @@ -Name: installPackage --- XXX -Version: 1.0 -Copyright: XXX -License: BSD3 --- XXX License-File: LICENSE -Author: XXX -Maintainer: XXX -Synopsis: XXX -Description: - XXX -Category: XXX -build-type: Simple -cabal-version: >=1.2 - ---Flag base3 --- Description: Choose the new smaller, split-up base package. - -Executable installPackage - Main-Is: installPackage.hs - Build-Depends: base, Cabal --- if flag(base3) --- Build-Depends: base >= 3 && < 4, --- directory >= 1 && < 1.1, --- process >= 1 && < 1.1 --- else --- Build-Depends: base < 3 - diff --git a/utils/installPackage/installPackage.hs b/utils/installPackage/installPackage.hs deleted file mode 100644 index 9ec7282592..0000000000 --- a/utils/installPackage/installPackage.hs +++ /dev/null @@ -1,154 +0,0 @@ - -import Control.Monad -import Data.Maybe -import Distribution.PackageDescription -import Distribution.PackageDescription.Parse -import Distribution.ReadE -import Distribution.Simple -import Distribution.Simple.Configure -import Distribution.Simple.LocalBuildInfo -import Distribution.Simple.Program -import Distribution.Simple.Setup -import Distribution.Simple.Utils -import Distribution.Text -import Distribution.Verbosity -import System.Environment - -main :: IO () -main - = do args <- getArgs - case args of - "install" : ghcpkg : ghcpkgconf : destdir : topdir : - iprefix : ibindir : ilibdir : ilibexecdir : idynlibdir : - idatadir : idocdir : ihtmldir : ihaddockdir : - args' -> - case parseArgs args' of - (verbosity, distPref, enableShellWrappers, strip) -> - doInstall verbosity distPref enableShellWrappers strip - ghcpkg ghcpkgconf destdir topdir - iprefix ibindir ilibdir ilibexecdir - idynlibdir idatadir idocdir ihtmldir - ihaddockdir - _ -> - error ("Bad arguments: " ++ show args) - --- XXX We should really make Cabal do the hardwork here -parseArgs :: [String] - -> (Verbosity, -- verbosity - FilePath, -- dist prefix - Bool, -- enable shell wrappers? - Bool) -- strip exe? -parseArgs = f normal defaultDistPref False True - where f _ dp esw strip (('-':'v':val):args) - = f (readEOrFail flagToVerbosity val) dp esw strip args - f v _ esw strip ("--distpref":dp:args) = f v dp esw strip args - f v dp _ strip ("--enable-shell-wrappers":args) = f v dp True strip args - f v dp esw _ ("--disable-executable-stripping":args) = f v dp esw False args - f v dp esw strip [] = (v, dp, esw, strip) - f _ _ _ _ args = error ("Bad arguments: " ++ show args) - -doInstall :: Verbosity -> FilePath -> Bool -> Bool - -> FilePath -> FilePath -> FilePath -> FilePath - -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath - -> FilePath -> FilePath -> FilePath -> FilePath - -> IO () -doInstall verbosity distPref enableShellWrappers strip - ghcpkg ghcpkgconf destdir topdir - iprefix ibindir ilibdir ilibexecdir idynlibdir idatadir - idocdir ihtmldir ihaddockdir = - do let userHooks = simpleUserHooks - copyto = if null destdir then NoCopyDest else CopyTo destdir - copyFlags = defaultCopyFlags { - copyDistPref = toFlag distPref, - copyUseWrapper = toFlag enableShellWrappers, - copyDest = toFlag copyto, - copyVerbosity = toFlag verbosity - } - registerFlags = defaultRegisterFlags { - regDistPref = toFlag distPref, - regPackageDB = toFlag GlobalPackageDB, - regVerbosity = toFlag verbosity, - regGenScript = toFlag $ False, - regInPlace = toFlag $ False - } - lbi <- getConfig verbosity distPref - let pd = localPkgDescr lbi - i = installDirTemplates lbi - -- This is an almighty hack. We need to register - -- ghc-prim:GHC.Prim, but it doesn't exist, get built, get - -- haddocked, get copied, etc. - pd_reg = if packageName pd == PackageName "ghc-prim" - then case library pd of - Just lib -> - let ems = fromJust (simpleParse "GHC.Prim") - : exposedModules lib - lib' = lib { exposedModules = ems } - in pd { library = Just lib' } - Nothing -> - error "Expected a library, but none found" - else pd - -- When coying, we need to actually give a concrete - -- directory to copy to rather than "$topdir" - toPathTemplate' = toPathTemplate . replaceTopdir topdir - i_copy = i { prefix = toPathTemplate' iprefix, - bindir = toPathTemplate' ibindir, - libdir = toPathTemplate' ilibdir, - dynlibdir = toPathTemplate' idynlibdir, - libexecdir = toPathTemplate' ilibexecdir, - datadir = toPathTemplate' idatadir, - docdir = toPathTemplate' idocdir, - htmldir = toPathTemplate' ihtmldir, - haddockdir = toPathTemplate' ihaddockdir - } - lbi_copy = lbi { installDirTemplates = i_copy, - stripExes = strip } - -- When we run GHC we give it a $topdir that includes the - -- $compiler/lib/ part of libsubdir, so we only want the - -- $pkgid part in the package.conf file. This is a bit of - -- a hack, really. - progs = withPrograms lbi - prog = ConfiguredProgram { - programId = programName ghcPkgProgram, - programVersion = Nothing, - programArgs = ["--force", "--global-conf", ghcpkgconf], - programLocation = UserSpecified ghcpkg - } - progs' = updateProgram prog progs - i_reg = i { prefix = toPathTemplate iprefix, - bindir = toPathTemplate ibindir, - libdir = toPathTemplate ilibdir, - dynlibdir = toPathTemplate idynlibdir, - libexecdir = toPathTemplate ilibexecdir, - datadir = toPathTemplate idatadir, - docdir = toPathTemplate idocdir, - htmldir = toPathTemplate ihtmldir, - haddockdir = toPathTemplate ihaddockdir - } - lbi_reg = lbi { installDirTemplates = i_reg, - withPrograms = progs' } - (copyHook simpleUserHooks) pd lbi_copy userHooks copyFlags - -- Cabal prints a scary "Package contains no library to register" - -- message if we call register but this is an executable package. - -- We therefore don't call it if we don't have a library for it. - when (isJust (library pd_reg)) $ - (regHook simpleUserHooks) pd_reg lbi_reg userHooks registerFlags - return () - -replaceTopdir :: FilePath -> FilePath -> FilePath -replaceTopdir topdir ('$':'t':'o':'p':'d':'i':'r':p) = topdir ++ p -replaceTopdir topdir ('$':'h':'t':'t':'p':'t':'o':'p':'d':'i':'r':p) - = topdir ++ p -replaceTopdir _ p = p - --- Get the build info, merging the setup-config and buildinfo files. -getConfig :: Verbosity -> FilePath -> IO LocalBuildInfo -getConfig verbosity distPref = do - lbi <- getPersistBuildConfig distPref - maybe_infoFile <- defaultHookedPackageDesc - case maybe_infoFile of - Nothing -> return lbi - Just infoFile -> do - hbi <- readHookedBuildInfo verbosity infoFile - return lbi { localPkgDescr = updatePackageDescription hbi (localPkgDescr lbi)} - - diff --git a/utils/mkdependC/Makefile b/utils/mkdependC/Makefile index 432c8981e4..0a67928259 100644 --- a/utils/mkdependC/Makefile +++ b/utils/mkdependC/Makefile @@ -1,24 +1,3 @@ -# -# Boilerplate Makefile for building perl script that -# needs some configured constants prepended to it. -# -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -boot :: all - -PROG=mkdependC -CLEAN_FILES += $(PROG) -all:: - $(RM) -f $(PROG) - echo '#!$(PERL)' >> $(PROG) - echo '$$DEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)";' >> $(PROG) - echo '$$CPP = "$(CPP)";' >> $(PROG) - echo '$$BUILDPLATFORM = "$(BUILDPLATFORM)";' >> $(PROG) - cat $(PROG).prl >> $(PROG) - $(EXECUTABLE_FILE) $(PROG) - -binary-dist: - @: - -include $(TOP)/mk/target.mk +dir = utils/mkdependC +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/mkdependC/ghc.mk b/utils/mkdependC/ghc.mk new file mode 100644 index 0000000000..4f43cc72dc --- /dev/null +++ b/utils/mkdependC/ghc.mk @@ -0,0 +1,12 @@ +$(MKDEPENDC) : utils/mkdependC/mkdependC.prl $(MKDIRHIER) + $(MKDIRHIER) $(dir $@) + $(RM) -f $@ + echo '#!$(PERL)' >> $@ + echo '$$DEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)";' >> $@ + echo '$$CPP = "$(CPP)";' >> $@ + echo '$$BUILDPLATFORM = "$(BUILDPLATFORM)";' >> $@ + cat utils/mkdependC/mkdependC.prl >> $@ + $(EXECUTABLE_FILE) $@ + +$(eval $(call all-target,utils/mkdependC,$(MKDEPENDC))) +$(eval $(call clean-target,utils/mkdependC,,$(MKDEPENDC))) diff --git a/utils/mkdependC/mkdependC.prl b/utils/mkdependC/mkdependC.prl index f7af53ac3c..166c3f16a7 100644 --- a/utils/mkdependC/mkdependC.prl +++ b/utils/mkdependC/mkdependC.prl @@ -122,6 +122,8 @@ sub mangle_command_line_args { push(@Defines, $2); } elsif ( /^(-optc)?(-I.*)/ ) { $Include_dirs .= " $2"; + } elsif ( /^(-optc)?(-isystem.*)/ ) { + $Include_dirs .= " $2"; } elsif ($Dashdashes_seen != 1) { # not between -- ... -- if ( /^-v$/ ) { diff --git a/utils/mkdirhier/Makefile b/utils/mkdirhier/Makefile index 0e32bbbde4..879e170be5 100644 --- a/utils/mkdirhier/Makefile +++ b/utils/mkdirhier/Makefile @@ -1,17 +1,3 @@ -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -boot :: all - -PROG=mkdirhier -CLEAN_FILES += $(PROG) -all:: - $(RM) -f $(PROG) - echo '#!$(SHELL)' >> $(PROG) - cat $(PROG).sh >> $(PROG) - $(EXECUTABLE_FILE) $(PROG) - -BINDIST_EXTRAS += $(PROG) -include $(TOP)/mk/bindist.mk - -include $(TOP)/mk/target.mk +dir = utils/mkdirhier +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/mkdirhier/ghc.mk b/utils/mkdirhier/ghc.mk new file mode 100644 index 0000000000..59ad53fe69 --- /dev/null +++ b/utils/mkdirhier/ghc.mk @@ -0,0 +1,11 @@ +$(MKDIRHIER) : utils/mkdirhier/mkdirhier.sh + -mkdir $(INPLACE) + -mkdir $(INPLACE_BIN) + -mkdir $(INPLACE_LIB) + $(RM) -f $@ + echo '#!$(SHELL)' >> $@ + cat utils/mkdirhier/mkdirhier.sh >> $@ + $(EXECUTABLE_FILE) $@ + +$(eval $(call all-target,utils/mkdirhier,$(MKDIRHIER))) +$(eval $(call clean-target,utils/mkdirhier,,$(MKDIRHIER))) diff --git a/utils/parallel/Makefile b/utils/parallel/Makefile index 50909c68e1..8b68d777b9 100644 --- a/utils/parallel/Makefile +++ b/utils/parallel/Makefile @@ -48,8 +48,6 @@ $(BASH_INSTALLERS): install.bash.%: cat $*.bash >> $(bindir)/$* $(EXECUTABLE_FILE) $(bindir)/$* -BINDIST_EXTRAS += $(addsuffix .pl,$(PERL_PROGS)) -BINDIST_EXTRAS += $(addsuffix .bash,$(BASH_PROGS)) include $(TOP)/mk/bindist.mk include $(TOP)/mk/target.mk diff --git a/utils/runghc/Makefile b/utils/runghc/Makefile index 1415921b04..fb5c1c1c55 100644 --- a/utils/runghc/Makefile +++ b/utils/runghc/Makefile @@ -1,12 +1,3 @@ - -TOP=../.. -ENABLE_SHELL_WRAPPERS = YES - -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal.mk - -distclean maintainer-clean: - $(RM) -f runghc.cabal - -# XXX Need to make runhaskell somehow - +dir = utils/runghc +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/runghc/ghc.mk b/utils/runghc/ghc.mk new file mode 100644 index 0000000000..1eb2d87c47 --- /dev/null +++ b/utils/runghc/ghc.mk @@ -0,0 +1,29 @@ +utils/runghc_dist_MODULES = Main +utils/runghc_dist_HC_OPTS = -cpp -DVERSION="\"$(ProjectVersion)\"" +utils/runghc_dist_PROG = runghc$(exeext) +utils/runghc_dist_SHELL_WRAPPER = YES +utils/runghc_dist_INSTALL_SHELL_WRAPPER = YES + +ifneq "$(BINDIST)" "YES" + +# hack: the build system has trouble with Main modules not called Main.hs +utils/runghc/dist/build/Main.hs : utils/runghc/runghc.hs $(MKDIRHIER) + $(MKDIRHIER) $(dir $@) + $(CP) $< $@ + +$(eval $(call build-prog,utils/runghc,dist,1)) + +endif + +install: install_runhaskell + +.PHONY: install_runhaskell +ifeq "$(Windows)" "YES" +install_runhaskell: install_bins + $(CP) $(DESTDIR)$(bindir)/runghc$(exeext) $(DESTDIR)$(bindir)/runhaskell$(exeext) +else +install_runhaskell: + $(RM) $(DESTDIR)$(bindir)/runhaskell + $(LN_S) runghc $(DESTDIR)$(bindir)/runhaskell +endif + diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index 47615def3a..aadafd9a71 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -22,8 +22,6 @@ module Main (main) where -import Paths_runghc - import Control.Exception import Data.Char import Data.List @@ -85,7 +83,7 @@ parseRunGhcFlags = f mempty printVersion :: IO () printVersion = do - putStrLn ("runghc " ++ showVersion version) + putStrLn ("runghc " ++ VERSION) printUsage :: IO () printUsage = do diff --git a/utils/touchy/ghc.mk b/utils/touchy/ghc.mk new file mode 100644 index 0000000000..022783fd3e --- /dev/null +++ b/utils/touchy/ghc.mk @@ -0,0 +1,5 @@ +utils/touchy_dist_C_SRCS = touchy.c +utils/touchy_dist_PROG = $(GHC_TOUCHY_PGM) +utils/touchy_dist_LIBEXEC = YES +utils/touchy_dist_INSTALL = YES +$(eval $(call build-prog,utils/touchy,dist,0)) diff --git a/utils/touchy/touchy.c b/utils/touchy/touchy.c index 90fb31e93e..dc4dc8d83f 100644 --- a/utils/touchy/touchy.c +++ b/utils/touchy/touchy.c @@ -11,6 +11,7 @@ #include <sys/types.h> #include <fcntl.h> #include <errno.h> +#include <utime.h> int main(int argc, char** argv) diff --git a/utils/unlit/Makefile b/utils/unlit/Makefile index 1723a08e26..b5ecc2dd47 100644 --- a/utils/unlit/Makefile +++ b/utils/unlit/Makefile @@ -1,25 +1,3 @@ -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -# Exclude for booting -ifeq "$(stage)" "2" -SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS) -SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS) -endif - -C_SRCS=unlit.c -C_PROG=unlit -SRC_CC_OPTS += -O - -# Get it over with! -boot :: all - -# -# Install unlit in lib/ -# -INSTALL_LIBEXECS += $(C_PROG) - -BINDIST_EXTRAS += $(C_PROG) -include $(TOP)/mk/bindist.mk - -include $(TOP)/mk/target.mk +dir = utils/unlit +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk new file mode 100644 index 0000000000..458092543d --- /dev/null +++ b/utils/unlit/ghc.mk @@ -0,0 +1,9 @@ +utils/unlit_dist_C_SRCS = unlit.c +utils/unlit_dist_PROG = $(GHC_UNLIT_PGM) +utils/unlit_dist_LIBEXEC = YES +utils/unlit_dist_INSTALL = YES + +ifneq "$(BINDIST)" "YES" +$(eval $(call build-prog,utils/unlit,dist,0)) +endif + diff --git a/utils/unlit/unlit.c b/utils/unlit/unlit.c index c5beeb1cbf..1269b81463 100644 --- a/utils/unlit/unlit.c +++ b/utils/unlit/unlit.c @@ -90,10 +90,8 @@ static char *ofilename = NULL; * if noisy is not set. */ -complain(file, lin, what) -char *file; -char *what; -int lin; { +void complain(char *file, int lin, char *what) +{ if (noisy) { if (file) fprintf(stderr, "%s ", file); @@ -102,7 +100,7 @@ int lin; { } } -writeerror() +void writeerror(void) { if (!strcmp(ofilename,"-")) { fprintf(stderr, CANNOTWRITESTDOUT); @@ -112,9 +110,8 @@ writeerror() exit(1); } -myputc(c, ostream) -char c; -FILE *ostream; { +void myputc(char c, FILE *ostream) +{ if (putc(c,ostream) == EOF) { writeerror(); } @@ -247,10 +244,8 @@ FILE *istream, *ostream; { * - there should be at least one DEFN line in a script. */ -unlit(file, istream, ostream) -char *file; -FILE *istream; -FILE *ostream; { +void unlit(char *file, FILE *istream, FILE *ostream) +{ line last, this=START; int linesread=0; int defnsread=0; @@ -317,9 +312,8 @@ FILE *ostream; { * position to specify the standard input or the standard output respectively. */ -main(argc,argv) -int argc; -char **argv; { +int main(int argc,char **argv) +{ FILE *istream, *ostream; char *file; |