gen-mach-types 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/awk
  2. #
  3. # Awk script to generate include/generated/machtypes.h
  4. # Heavily based on arch/arm/tools/gen-mach-types
  5. #
  6. BEGIN { nr = 0 }
  7. /^#/ { next }
  8. /^[ ]*$/ { next }
  9. NF == 2 {
  10. mach[nr] = $1;
  11. config[nr] = "CONFIG_"$2;
  12. nr++;
  13. }
  14. END {
  15. printf("/*\n");
  16. printf(" * Automagically generated, don't touch.\n");
  17. printf(" */\n");
  18. printf("#ifndef __ASM_SH_MACHTYPES_H\n");
  19. printf("#define __ASM_SH_MACHTYPES_H\n");
  20. printf("\n");
  21. printf("/*\n");
  22. printf(" * We'll use the following MACH_xxx defs for placeholders for the time\n");
  23. printf(" * being .. these will all go away once sh_machtype is assigned per-board.\n");
  24. printf(" *\n");
  25. printf(" * For now we leave things the way they are for backwards compatibility.\n");
  26. printf(" */\n");
  27. printf("\n");
  28. printf("/* Mach types */\n");
  29. for (i = 0; i < nr; i++) {
  30. printf("#ifdef %s\n", config[i]);
  31. printf(" #define MACH_%s\t\t1\n", mach[i]);
  32. printf("#else\n");
  33. printf(" #define MACH_%s\t\t0\n", mach[i]);
  34. printf("#endif\n");
  35. }
  36. printf("\n");
  37. printf("/* Machtype checks */\n");
  38. for (i = 0; i < nr; i++)
  39. printf("#define mach_is_%s()\t\t\t(MACH_%s)\n",
  40. tolower(mach[i]), mach[i]);
  41. printf("\n");
  42. printf("#endif /* __ASM_SH_MACHTYPES_H */\n");
  43. }