MMAKE(1)

πŸ“¦
version 2.3 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

🌸 MMAKE(1) β€” the User Commands era πŸ’…

okay bestie, this is mmake, and yes it lives in the User Commands chapter of the manual. sit down, grab a strawberry drink πŸ“, we're making Java Makefiles and it's gonna be iconic.


✨ NAME ✨

mmake β€” generate a Java Makefile. that's it. that's the whole job. and it ate. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

mmake [ -d βŽͺ -v ]
ngl that pipe in the middle is giving "quirky" but we keep it exactly as it is, no cap. 🫢

πŸ’– DESCRIPTION πŸ’–

so this program generates a Makefile for Java source files. if you want everything handed to you on a lil velvet pillow, use the -d option to accept all defaults. periodt.

after running mmake, you'll get a Makefile in the directory you started the program from. that Makefile handles java files in the current directory and in any sub-directories. she's thorough. she's organized. main character energy fr. ✨

here's how you use the generated Makefile with mmake:

to compile Java files you literally just type make. that's it, that's the vibe. 🌈

you can also run make with one of these targets: doc, clean, help, jar, srcjar, bundle, install, uninstall, tags and depend. let's break them down because the way that each one does something different is so satisfying:

  • make doc β€” runs javadoc on the source files. heads up though: it will only work for files in a package. πŸ’€
  • make clean β€” removes class files and other temporary files. a lil reset, a lil cleanse, we love a fresh start 🧚
  • make jar β€” creates a jar file with all class files (and other files of your choice, see the JAR_OBJS variable in the Makefile).
  • make srcjar β€” creates a jar file with all java files.
  • make bundle β€” creates a Mac OS X Application Bundle with all the jar file.
  • make install β€” will install a jar file, app bundle, class files and any shell wrappers you have made. (a shell script must have the extension .sh to be installed).
  • make uninstall β€” use this to remove installed files. bye bye, we hardly knew ye πŸ‘‹
  • make help β€” shows a help text with available targets. self-explanatory queen.
  • make tags β€” will generate a tag file for Emacs.
  • make depend β€” creates a dependency graph for the class files. (the dependency graph will be put in a file called makefile.dep, which is included in the Makefile).

okay so here's the cute part: you don't have to run mmake each time you add a new java file to your project. you can add as many new java files as you like, the Makefile will find them. slay. πŸ’…

but β€” and this is the one caveat, lowkey important β€” this is the case as long as you don't add a new package. in that case, you must either run mmake again or update the PACKAGE variable in the Makefile. this is because the Makefile uses this variable to find directories with java files. don't forget it, bestie. πŸ™ˆ

the program mmake is able to create a dependency graph for your java files. to do this, it needs the jikes compiler from IBM. get jikes from http://www.ibm.com/developerworks/oss/jikes/. you would probably be more content with jikes anyhow, since it is much faster than javac. to create a dependencies graph, do a make clean before running make depend.


πŸŽ€ A NOTE ON INSTALLATION πŸŽ€

the Makefile created with mmake will do a fair job installing the different files that makes up your system. it uses the following Makefile variables when it conducts the install routine:

  • PREFIX
  • CLASS_DIR
  • JAR_DIR
  • BUNDLE_DIR
  • DOC_DIR
  • SCRIPT_DIR

let's go one by one, we're being thorough today πŸ’œ

PREFIX

this variable will be prepended to all other directory variables above. it is used for grouping the other directories into one root directory. if you don't want that, you may simply set the variable to an empty string in the Makefile. if the variable is empty you could still use it on the command line when you run make, for instance for a one-shoot installation like:

make PREFIX=/local/myproject/ install

CLASS_DIR

this variable denotes the top directory from where all class files will be installed. its default value is classes, which I believe is a good value. note: if you don't want to install any class files (because you are, for example, only going to use a jar file), set this variable to an empty string and no class files will be installed.

resource files will also be installed below this directory if such files are present in a package structure. this is useful if you are using e.g. ResourceBundles to Localize your application and have your property files in it's own directory in the package structure. ✨

JAR_DIR

this variable tells the Makefile where to install the jar file. the default value is lib, which is also a good default value.

BUNDLE_DIR

this variable tells the Makefile where to install the app bundle. the default value is lib, which is also a good default value.

DOC_DIR

when you run javadoc, all the html files will be put into this directory. its default value is doc/api-docs. you should probably keep that name, but then again, you may change it as you like. live your truth. πŸ¦‹

SCRIPT_DIR

the Makefile uses this variable to install any shell wrapper-scripts that you have created. if you write an application, it is always nice for the user that you provide a wrapper script to start the application. its default value is bin. (the Makefile will only install shell-scripts that has the extension .sh. the mmake script will tell the Makefile where to look for shell-scripts)

INSTALLATION SUMMARY πŸ“¦

if you keep the default values you will get an installation tree that looks like this:

 `-- PREFIX
     βŽͺ-- bin
     βŽͺ-- classes
     βŽͺ   `-- package <--- Example of a sub-directory
     βŽͺ       βŽͺ-- sub-package1
     βŽͺ       βŽͺ-- sub-package2
     βŽͺ       `-- sub-package3
     βŽͺ-- doc
     βŽͺ   `-- api-docs
     `-- lib

look at that structure. organized. pristine. it's giving ✨feng shui✨


🌈 USING THE C-PREPROCESSOR 🌈

this is a excellent tool for managing projects with several different versions. the idea behind using the C preprocessor with Java is to better manage different versions more easily. this is done by using CPP conditional statements in the source files.

I would strongly advise you not to use CPP to redefine the Java language itself. like, do not do that. 🚫

to use the C preprocessor together with Java, you can change the name of the source files that you want to preprocess β€” from <filename>.java to <filename>.xjava. the Makefile has a rule to build .class files from .xjava files. iconic.

it is not necessary to change every file from .java to .xjava. the Makefile will work well and consistently in an environment of both .java and .xjava files. (e.g. make clean will only remove .java files that were created from a .xjava file. other java files will, of course, not be removed.)

you can now use cpp Conditionals in Your Java-code, for example, as follows:

#ifdef JAVA1_1
   [code1]
#else
   [code2]
#endif

the JAVA1_1 label in the above example is tested against the VERSION variable in the Makefile. that is, if the VERSION variable is JAVA1_1, then [code1] would be compiled and [code2] left out. likewise, if VERSION is something else than JAVA1_1, then [code2] would be compiled and [code1] left out of the resulting .class file. conditional queen behavior, honestly. πŸ’…


πŸ’€ NOTES πŸ’€

mmake will give you one Makefile for managing your Java files. although it's easy to setup and use mmake in a recursive makefile context, you don't want to do that. to see why, read the excellent article: Recursive Make Considered Harmful at http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html.

like. trust. don't. 😭


🫢 DEPENDENCIES 🫢

mmake will need the following:

  • Perl 5.x
  • Gnu make
  • Gnu xargs (recommended)

πŸ‘‘ AUTHOR πŸ‘‘

Jan-Henrik Haukeland <hauk@tildeslash.com>


and that's the whole page, bestie πŸ’– this one dropped on April 2. 2004 and lives over at www.tildeslash.com β€” so yeah, shoutout to the MMAKE(1) era, we stan a classic. 🌸✨